{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1164
  Verdict: Accepted
}
uses 
	SysUtils, Math;
 
var  	
	i,n,q,x,y:longint;
	a:array[0..100010] of longint;
 
function siftup(i:longint):longint;
 
var 
	t:longint;
 
begin
while (i>1) and (a[i div 2]<a[i]) do begin
  t:=a[i];
  a[i]:=a[i div 2];
  a[i div 2]:=t;
  i:=i div 2;
end;
result:=i;
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=1 to n do
	read(a[i]);
read(q);
for i:=1 to q do begin
	read(x,y);
	inc(a[x],y);
	writeln(siftup(x));
end;
for i:=1 to n do
	write(a[i],' ');
end.